package kevin.framework.basic.common.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName: DynamicParameter
 * @Description: TODO
 * @author kevin.huang
 * @date 2016年4月23日 下午1:46:20
 */
public class DynamicParameter {
	private Integer page; // 当前页
	private Integer size; // 页大小
	private Map<String, Object> params; // 传入的参数
	private Map<String, String> orderMap;

	public void setOrderMap(Map<String, String> orderMap) {
		this.orderMap = orderMap;
	}

	public List<String> getOrderColumn() {
		List<String> temp = new ArrayList<String>();
		if (orderMap != null) {
			Set<Map.Entry<String, String>> keySet = orderMap.entrySet();
			for (Map.Entry<String, String> entry : keySet) {
				String key = entry.getKey().replaceAll(".*([';]+|(--)+).*", " ").replaceAll("<", "&lt;")
						.replaceAll(">", "&gt;").replaceAll("delete|truncate|exec", "");
				String val = entry.getValue().replaceAll(".*([';]+|(--)+).*", " ").replaceAll("<", "&lt;")
						.replaceAll(">", "&gt;").replaceAll("delete|truncate|exec", "");
				if (StringUtils.isNoneEmpty(key) && StringUtils.isNoneEmpty(val)) {
					temp.add(key + " " + val);
				}
			}
		}
		return temp;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getSize() {
		return size;
	}

	public void setSize(Integer size) {
		this.size = size;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}
}
